package com.wx.mythread.sixstatus;

/**
 * 展示线程的三种状态：
 * NEW
 * RUNABLE
 * TERMINATED
 * 即使是正在运行，也是RUNABLE状态，而不是RUNNING。
 */
public class NewRunableTerminated implements Runnable{

    public static void main(String[] args) {
        Thread thread = new Thread(new NewRunableTerminated());
        //打印出NEW的状态
        System.out.println(thread.getState());
        thread.start();
        //打印出RUNABLE状态
        System.out.println(thread.getState());
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //打印出RUNABLE状态，即使是正在运行，也是RUNABLE，而不是RUNNING
        System.out.println("我是运行中的状态："+thread.getState());
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //打印出TERMINATED状态
        System.out.println(thread.getState());
    }

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            System.out.println(i);
        }
    }
}
